package com.wkq.dao;

import com.wkq.domain.Role;
import com.wkq.domain.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IUserDao {

    @Select(" select id, username, email, password, phoneNum, status from users where username = #{username} ")
    public UserInfo findByUsername (String username);

    @Select(" select id, username, email, password, phoneNum, status from users ")
    public List<UserInfo> findAll ();

    @Insert(" insert into users(username, email, password, phoneNum, status) values(#{username}, #{email}, #{password}, #{phoneNum}, #{status}) ")
    public int save (UserInfo userInfo);

    @Select(" select id, username, email, password, phoneNum, status from users where id = #{id} ")
    public UserInfo findById (int id);

    @Select(" select id, roleName, roleDesc from role where id = #{id} ")
    public List<Role> findOtherRole (int id);

    public int addRoleToUser (@Param("userId") String userId, @Param("roleId") List<String> roleId);
}
